﻿/***************************************************************************
    Copyright (c) Microsoft Corporation. All rights reserved.
    This code is licensed under the Visual Studio 
    Visualization and Modeling SDK license terms.

    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
***************************************************************************/
using System.Linq;

namespace Microsoft.VisualStudio.ArchitectureTools.CodeRepositoryQuery
{
    /// <summary>
    /// Property
    /// </summary>
    partial class Property : IMember
    {
        #region IMember Members
        /// <summary>
        /// Access for the property
        /// </summary>
        public AccessType Access
        {
            get
            {
                short? access = this.AccessorMethodDefinitions.Max(m => m.AccessAsShort);
                if (access.HasValue)
                {
                    return (AccessType)access.Value;
                }
                else
                {
                    throw new System.NotImplementedException("a Property must have at least a get or a set method");
                }
            }
        }

        #endregion

        /// <summary>
        /// Display label
        /// </summary>
        public override string ToString()
        {
            return this.Name;
        }
    }

}
